﻿@model IEnumerable<trangbaocao.Models.FuelGeneratorModel>        
<!--Body-->
<div align="center" style="margin-bottom:10px;"><h1>QUẢN LÝ NHIÊN LIỆU MÁY PHÁT ĐIỆN</h1></div>
<br>
<h2 align="center">THÁNG  @ViewBag.thang
    
    NĂM @DateTime.Now.Year.ToString()
</h2>
<div class="container_12">
    <div class="grid_12">
        <!-- Notification boxes -->
        @if (TempData["msg"] != null)
        {                            
            <span class="notification n-success">@TempData["msg"]</span>
        }
        @if (TempData["error"] != null)
        {                            
            <span class="notification n-error">@TempData["error"]</span>
        }  
        @using (Html.BeginForm("FindFuelGenerator", "Fuel", FormMethod.Post, new { id = "FindFuelGenerator", name = "FindFuelGenerator" }))
        {
            <input type="hidden" name="thang_hidden" id="thang_hidden" />               
                   @*<div style="padding-left:5px; margin-bottom:5px; text-align:left; width:40%">
                       <lable style="margin-right:3px">Trung tâm: </lable>
                        @if (ViewBag.trungtam_id != null)
                        {  
                            @Html.DropDownList("main_stations_id", ViewBag.trungtam_id as SelectList, "---Chọn trung tâm---")
                        }
                    </div>*@
                    @*<p style="text-align:left; width:40%;padding-left:5px">
                        Trạm:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
                    @Html.DropDownList("stations_id", Enumerable.Empty<SelectListItem>(), "---Chọn nhà trạm---")
                    </p>*@
            @*<div class="bottom-spacing">
                Tìm kiếm:
                <select name="select_option" style="width:22.3%; margin-left:7px">
                    <option value="device_stations.ma_he_thong"  @(ViewBag.find_selectbox == "device_stations.ma_he_thong" ? "selected" : "") >Mã thiết bị</option>
                    <option value="device_stations.name"  @(ViewBag.find_selectbox == "device_stations.name" ? "selected" : "") >Tên thiết bị</option>                    
                </select>
                <input type="text" class="input-short" name="timkiem" value="@ViewBag.find_textbox" style="width:20%; margin-left:20px" />
                <input class="submit-green" type="button" onclick="submitForm()" value="Tìm kiếm" style="width:8.5%; padding-left:3px"  />                
            </div> *@
        }      
        @using (Html.BeginForm("CheckedActionGenerator", "Fuel", FormMethod.Post, new { id = "CheckedActionGenerator", name = "CheckedActionGenerator" }))
        { 
        <input type="hidden" name="thang" value="@ViewBag.thang" />  
        <input type="hidden" name="main_stations_id" value="@ViewBag.main_stations_id" />    
        <!-- Example table --> 
        <div class="module">
            <h2 align="right"><span align="right"><a href="@Url.Action("GeneratorIndex", "Fuel", new { @ViewBag.thang })">Quay lại</a></span></h2>                    
            @* <div class="module-table-body">
                <table id="myTable" class="tablesorter">*@
                <div class="module-table-body">
                    <div class="scrolling">
                        <div class="data-table" style="width:100%">
                            <table id="myTable" class="tablesorter">
                                <thead>
                                    <tr>
                                        <th style="width:5%;">STT</th>
                                        <th style="width:4.5%;">Chọn</th>
                                        <th style="width:4.5%;">Xóa</th>
                                        <th style="width:4.5%;">Sửa</th>
                                        <th style="width:9%;">Ngày nhập</th>
                                        @*<th style="width:12%;">Tên trung tâm</th>*@
                                        <th style="width:18%;">Nhập trong tháng(lít)</th>
                                        <th style="width:8%;">Đơn giá</th>
                                        <th style="width:10%;">Tổng tiền</th>                                        
                                        <th style="width:10%;">Ghi chú</th>
                                    </tr>
                                </thead>
                                <tbody>
                    @{int stt = 0;}
                    @foreach (var item in Model)
                    {
                        stt++;
                        <tr> 
                            <td class="align-left">@stt</td>                          
                             <td class="align-center"><input type="checkbox" name="Items" id="Items[]" value="@item.id"/></td>
                            <td><a href="@Url.Action("DeleteGeneratorDetail", "Fuel", new { id = item.id, main_stations_id = item.main_stations_id, thang = item.thang })" onclick="return confirm('Bạn muốn xóa thông tin này?');" title="Xóa thông tin"><img src="../../Content/Body/Images/cross-on-white.gif" width="16" height="16" alt="delete" /></a></td>    
                            <td>
                                <a onclick="SendValue(@item.id)" target="_blank" style="cursor:pointer" title="Cập nhật thông tin"><img src="../../Content/Body/Images/pencil.gif"  width="16" height="16" alt="edit" /></a>
                             </td> 
                            <td> @Html.DisplayFor(modelItem => item.ngay_nhap)</td>  
                            @*<td> @Html.DisplayFor(modelItem => item.ten_trung_tam)</td>*@
                            <td> @Html.DisplayFor(modelItem => item.nhap_trong_thang)</td>
                            <td> @Html.DisplayFor(modelItem => item.don_gia)</td>
                            <td> @Html.DisplayFor(modelItem => item.tong_tien)</td>                            
                            <td> @Html.DisplayFor(modelItem => item.ghi_chu)</td>
                        </tr>
                    }   
                    </tbody>
                </table>
                </div></div>
                <div class="pager" id="pager">
                    <div>
                    <img class="first" src="../../Content/Body/Images/arrow-stop-180.gif"  alt="first"/>
                    <img class="prev" src="../../Content/Body/Images/arrow-180.gif" alt="prev"/> 
                    <input type="text" class="pagedisplay input-short align-center"/>
                    <img class="next" src="../../Content/Body/Images/arrow.gif" alt="next"/>
                    <img class="last" src="../../Content/Body/Images/arrow-stop.gif" alt="last"/> 
                    <select class="pagesize input-short align-center">
                        <option value="20" selected="selected">20</option>
                        <option value="30">30</option>
                        <option value="40">40</option>
                    </select>
                    </div>
                </div>
                <div class="table-apply"> 
                    <div class="float-right">
                        <a style='cursor:pointer' onclick="return CheckItem();" class="button">
                            <span>Xóa chọn</span>
                        </a>
                    </div>                        
                </div>   
                <div style="clear: both"></div>
            </div> <!-- End .module-table-body -->
        </div> <!-- End .module --> 
        }                                                               
	</div> <!-- End .grid_12 -->            
    <div style="clear:both;"></div>            
</div> <!-- End .container_12 -->
<!----------------------------------------------------------------->
<script language="javascript" type="text/javascript">    
    function SendValue(id) {
        //window.location.href = '@Url.Action("GeneratorDetailEdit", "Fuel")/' + '?id'=+id+ '&main_stations_id=' + @ViewBag.main_stations_id + '&thang=' + @ViewBag.thang;
        window.location.href = '@Url.Action("GeneratorDetailEdit", "Fuel")/' + '?id=' + id + '&main_stations_id='+@ViewBag.main_stations_id+ '&thang=' + @ViewBag.thang;
    }
</script>
<script type="text/javascript">
    $("#thang").change(function () {
        document.getElementById('thang_hidden').value = this.value;
        $('#FindFuelGenerator').submit();
    });
</script>

<script language="javascript" type="text/javascript">
    function CheckItem() {
        var arrCheckboxes = document.getElementsByName('Items');
        var checkCount = 0;
        for (var i = 0; i < arrCheckboxes.length; i++) {
            checkCount += (arrCheckboxes[i].checked) ? 1 : 0;
        }
        if (checkCount > 0) {
            if (confirm("Bạn chắc chắn muốn xóa thông tin đã chọn?"))
                document.forms["CheckedActionGenerator"].submit();
        } else {
            alert("Bạn chưa chọn thông tin cần xóa!");
            return false;
        }
    }
</script>
@*<script type="text/javascript">
    $("#main_stations_id").change(function () {
        $.ajax({
            type: "POST",
            url: '@Url.Action("getStationsJson", "Device_Stations")',
            data: { MainStationId: $("#main_stations_id > option:selected").attr("value"), Order: "name" },
            success: function (data) {
                var items = [];
                items.push("<option>---Chọn nhà trạm---</option>");
                $.each(data, function () {
                    items.push("<option value=" + this.Value + ">" + this.Text + "</option>");
                });
                $("#stations_id").html(items.join(' '));
            }
        })
    });
</script>*@
    

           

	